import java.awt.*;
import javax.swing.*;

class AthleteLoginGUI extends JFrame {
    // 声明类的成员属性
    private JLabel lbNo, lbSports, lbRace; // 编号、运动项目、参赛项目标签
    private JTextField tfNo; // 输入编号的文本框
    private JRadioButton rbNan, rbNv; // 男，女单选按钮
    private ButtonGroup grp; // 单选按钮组
    private JComboBox<String> jcSports; // 运动项目下拉列表框
    private JTextArea jtRace; // 参赛项目文本区域
    private JScrollPane jsRace; // 参赛项目文本区域滚动面板
    private JButton btnReset, btnExit; // 重置和退出按钮
    private JPanel jp1, jp2, jp3, jp4, jp5; // 5个面板

    public AthleteLoginGUI(String title) {
        super(title);
        setLayout(new GridLayout(5, 1));

        // 创建面板、组件对象
        jp1 = new JPanel();
        jp2 = new JPanel();
        jp3 = new JPanel();
        jp4 = new JPanel();
        jp5 = new JPanel();

        tfNo = new JTextField(10);

        lbNo = new JLabel("输入运动员的编号：");
        lbSports = new JLabel("请选择参加的运动项目：");
        lbRace = new JLabel("运动员参赛项目：");
        rbNan = new JRadioButton("男", true);
        rbNv = new JRadioButton("女");
        grp = new ButtonGroup();
        grp.add(rbNan);
        grp.add(rbNv);
        jcSports = new JComboBox<String>();
        jcSports.addItem("跳远");
        jcSports.addItem("600米赛跑");
        jcSports.addItem("跳高");
        jcSports.addItem("4*100接力赛");
        jtRace = new JTextArea(30, 30);
        jsRace = new JScrollPane(jtRace);

        // 设置滚动面板的滚动条为垂直滚动条
        jsRace.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        btnReset = new JButton("重置");
        btnExit = new JButton("退出");

        // 将组件添加到面板
        jp1.add(lbNo);
        jp1.add(tfNo);

        jp2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "选择性别"));
        jp2.add(rbNan);
        jp2.add(rbNv);

        jp3.add(lbSports);
        jp3.add(jcSports);

        jp4.setLayout(new GridLayout(2, 1));
        jp4.add(lbRace);
        jp4.add(jsRace);

        jp5.add(btnReset);
        jp5.add(btnExit);

        // 将面板添加到窗体
        add(jp1);
        add(jp2);
        add(jp3);
        add(jp4);
        add(jp5);

        pack();
        setVisible(true);
    }

    public static void main(String[] args) {
        new AthleteLoginGUI("运动员登录");
    }
}